<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // 1. 定义对象
    const obj = {
      name: '张三',
      age: 18,
      sayHi: function() {
        console.log('你好');
      }
    }
    // 2. 遍历对象
    for (let key in obj) {
      console.log(key+':'+obj[key]);
    }
  </script>
</body>
</html>